package com.edu.exam.enums.grading;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 批阅会话状态枚举
 *
 * <p>定义批阅会话的各种状态，从活跃到终止。</p>
 *
 * @author System
 * @version 1.0.0
 * @since 2025-11-13
 */
public enum SessionStatus implements BaseEnum {

    /** 活跃 */
    ACTIVE("ACTIVE", "活跃"),

    /** 非活跃 */
    INACTIVE("INACTIVE", "非活跃"),

    /** 已过期 */
    EXPIRED("EXPIRED", "已过期"),

    /** 已终止 */
    TERMINATED("TERMINATED", "已终止");

    private final String code;
    private final String description;

    SessionStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static SessionStatus fromCode(String code) {
        for (SessionStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown session status code: " + code);
    }

    public static SessionStatus fromDescription(String description) {
        for (SessionStatus status : values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown session status description: " + description);
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}